package org.jeecg.modules.logistics.manage.hz_info.controller;

import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.modules.logistics.manage.hz_info.entity.HzInfo;
import org.jeecg.modules.logistics.manage.hz_info.service.IHzInfoService;
import org.jeecg.modules.logistics.manage.sj_info.entity.SjInfo;

import org.jeecg.modules.logistics.manage.wljd_info.entity.WljdInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 货主全部信息
 * @Author: 唐小尊
 * @Date: 2019-11-04
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "货主全部信息")
@RestController
@RequestMapping("/my/hzInfo")
public class HzInfoController {
    @Autowired
    private IHzInfoService hzInfoService;

    /**
     * 得到一个货主信息
     *
     * @param hzId
     * @return
     */
    @AutoLog(value = "得到一个货主信息")
    @ApiOperation(value = "得到一个货主信息", notes = "得到一个货主信息")
    @GetMapping(value = "/getOneHzInfo")
    public Result<HzInfo> getOneHzInfo(String hzId) {
        Result<HzInfo> result = new Result<HzInfo>();
        HzInfo hzInfo = new HzInfo();
        try {
            hzInfo = hzInfoService.getOneHzInfo(hzId);
            result.setResult(hzInfo);
            result.success("查找成功！");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.setResult(hzInfo);
            result.error500("操作失败");
        }
        return result;
    }

    /**
     * 得到12个货主信息
     * @param thisIndex
     * @return
     */
    @AutoLog(value = "得到12个货主信息")
    @ApiOperation(value = "得到一个货主信息", notes = "得到一个货主信息")
    @GetMapping(value = "/getHzInfoList")
    public Result<List<HzInfo>> getHzInfoList() {
        Result<List<HzInfo>> result = new Result<List<HzInfo>>();
        List<HzInfo> hzInfos = new ArrayList<>();
        try {
            hzInfos = hzInfoService.getHzInfoList();
            result.setResult(hzInfos);
            result.success("查找成功！");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.setResult(hzInfos);
            result.error500("操作失败");
        }
        return result;
    }

    /**
     * 得到12个货主信息
     * @param userId
     * @return
     */
    @AutoLog(value = "得到12个货主信息")
    @ApiOperation(value = "得到一个货主信息", notes = "得到一个货主信息")
    @GetMapping(value = "/getOneHzAllWljd")
    public Result<List<WljdInfo>> getOneHzAllWljd(String userId) {
        Result<List<WljdInfo>> result = new Result<List<WljdInfo>>();
        List<WljdInfo> wljdInfos = new ArrayList<>();
        wljdInfos = hzInfoService.getOneHzAllWljd(userId);
        return result;
    }

}
